package org.byqh.dqeai.config.easyquery;

import com.easy.query.api.proxy.client.EasyEntityQuery;
import com.easy.query.core.api.client.EasyQueryClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class EasyQueryService {
    @Autowired
    private Map<String, EasyEntityQuery> mapEasyEntityQuery;
    @Autowired
    private Map<String, EasyQueryClient> mapEasyQueryClient;

    private static <T> String getBeanName(Class<T> clazz, String database) {
        return clazz.getSimpleName() + "_" + database;
    }

    public EasyEntityQuery getEasyEntityQuery(String database) {
        return mapEasyEntityQuery.get(getBeanName(EasyEntityQuery.class, database));
    }

    public EasyQueryClient getEasyQueryClient(String database) {
        return mapEasyQueryClient.get(getBeanName(EasyQueryClient.class, database));
    }
}
